package com.yunxi.config;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Guan on 2020/3/18.
 */
public class EnumsOrderCustomer {

    public static enum OrderStatus {
        WAIT_PAY(1,"待付款"),
        SMALL_PAYED(2,"小订已付款"),
        BIG_PAYED(3,"大定已付款"),
        EVALED(4,"订单已评价"),
        TIMEOUTED(5,"已超时"),
        SMALL_CANCEL(6,"小订已取消"),
        SMALL_REFUND(7,"小订申请退款"),
        SMALL_REFUNDED(8,"小订退款成功"),
        SMILL_REFUND_FAIL(9,"小订退款失败")
        ;

        private String value;
        private int code;

        private OrderStatus(int code,String value) {
            this.value = value;
            this.code = code;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public static String getValue(int code) {
            for (OrderStatus orderStatus : OrderStatus.values()) {
                if (orderStatus.getCode() == code) {
                    return orderStatus.value;
                }
            }
            return null;
        }

        public static List getList() {
            List<Map> list = new ArrayList<Map>();
            for (OrderStatus orderStatus : OrderStatus.values()) {
                Map map = new HashMap();
                map.put("key", orderStatus.getCode());
                map.put("value", orderStatus.getValue());
                list.add(map);
            }
            return list;
        }
    }

    public static enum OrderSource {
        APP(1,"APP"),
        PC(2,"PC"),
        PAD(3,"PAD"),
        ADMIN(9,"后台录入"),
        ;

        private String value;
        private int code;

        private OrderSource(int code,String value) {
            this.value = value;
            this.code = code;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public int getCode() {
            return code;
        }

        public void setCode(int code) {
            this.code = code;
        }

        public static String getValue(int code) {
            for (OrderSource orderSource : OrderSource.values()) {
                if (orderSource.getCode() == code) {
                    return orderSource.value;
                }
            }
            return null;
        }

        public static List getList() {
            List<Map> list = new ArrayList<Map>();
            for (OrderSource orderSource : OrderSource.values()) {
                Map map = new HashMap();
                map.put("key", orderSource.getCode());
                map.put("value", orderSource.getValue());
                list.add(map);
            }
            return list;
        }
    }
}
